*     *****************************************************************   *;
*     *****************************************************************   *; 
*   Date:          December 27, 2021                               	      *;
*   Authors:       Lisa Dellmuth and Jonas Tallberg				          *;  
*   Purpose: 	   Analyses for book Legitimacy Politics: Elite  		  *;
*    Communication and Public Opinion in Global Governance (CUP, 2023)    *;
*     ****************************************************************    *;
*     ****************************************************************    *;

*Chapter 7

ssc install blindschemes
set scheme plotplain
ssc install coefplot



*Figure 7.3
*************************************

use "purpose_us_pooled.dta", clear

tab Q5, nol
tab intcoop 

gen one=1
graph bar (percent) one [aweight=weight], title(US) ytitle(Internationalist attitudes (%)) over(intcoop) saving(intcoop_us.gph, replace)

use "purpose_de_pooled.dta", clear
set scheme plotplain
gen one=1
graph bar (percent) one [aweight=weight], title(Germany) ytitle(Internationalist attitudes (%)) over(intcoop) saving(intcoop_de.gph, replace) 
graph combine intcoop_us.gph intcoop_de.gph, ycommon

// black, intensity 80%

*Figure 7.4
*************************************

use "purpose_us_pooled.dta", clear

tab lr, nol
tab Q11  

gen one=1
graph bar (percent) one [aweight=weight], title(US) ytitle(Left-right (%)) over(lr) saving(lr_us.gph, replace)

use "purpose_de_pooled.dta", clear

tab lr, nol
tab Q11  

gen one=1
graph bar (percent) one [aweight=weight], title(Germany) ytitle(Left-right (%)) over(lr) saving(lr_us.gph, replace)

graph combine Fig7.4a.gph Fig7.4b.gph, ycommon

// black, intensity 80%


*Regression models and corresponding figures
*************************************


use "purpose_us_pooled.dta", clear

tab attentive
regress conf_cont i.power i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
estimates store conf_cont_us

*ACME graphs


*continuous DV - Fig 7.5
#delimit ;
coefplot(conf_cont_us), headings(1.power="{bf:Authority}" 1.purposeR2="{bf:Social Purpose}" 
1.transR="{bf:Transparency}" 1.partR="{bf:Participation}"
1.fairR="{bf:Fair Outcome}" 1.problemR="{bf:Problem-solving}") 
xline(0) drop(_cons) title("US") fxsize(60) base xtitle(Average marginal effects)
saving(conf_cont_us.gph, replace)
;
#delimit cr


use "purpose_de_pooled.dta", replace

tab attentive
regress conf_cont i.purposeR2 i.power ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
estimates store conf_cont_de

*ACME graphs


*continuous DV - Fig 7.6
#delimit ;
coefplot(conf_cont_de) , headings(1.purposeR2="{bf:Social Purpose}" 
1.power="{bf:Authority}" 1.transR="{bf:Transparency}" 1.partR="{bf:Participation}"
1.fairR="{bf:Fair Outcome}" 1.problemR="{bf:Problem-solving}") 
xline(0) drop(_cons) title("Germany") fxsize(60) base xtitle(Average marginal effects)
saving(conf_cont_de.gph, replace)
;
#delimit cr





*Figure 7.7 - AMCE - see separate code for marginal means


use "purpose_us_pooled.dta", clear

tab intcoop, nol
regress conf_cont i.power##c.intcoop i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
qui margins, at(intcoop=(0(1)2) ) vsquish vce(uncond) dydx(power) saving(margins_intcoop_power_us, replace) 
use margins_intcoop_power_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3 

*MARGINSPLOT USING TWOWAY
set scheme plotplain

twoway ///
(connected _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// some power
(connected _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// extensive power 
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// some power
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)), ///   extensive power
ytitle("Marginal effects of authority, with 95% CIs") ///
xtitle("Left-right ideology") ///
xla(1(1)11, valuelabel) xlabel(1 "a bad thing" 2 "neither good nor bad" 3 "a good thing") graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Some power" 2 "Extensive power")) ///
saving(int_intcoop_us, replace) title(US)




*Figure 7.8 - AMCE - see separate code for marginal means


use "purpose_de_pooled.dta", clear

tab intcoop, nol
regress conf_cont i.power##c.intcoop i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
qui margins, at(intcoop=(0(1)2) ) vsquish vce(uncond) dydx(power) saving(margins_intcoop_power_de, replace) 
use margins_intcoop_power_de.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3 

*MARGINSPLOT USING TWOWAY
twoway ///
(connected _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// some power
(connected _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// extensive power 
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// some power
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)), ///   extensive power
ytitle("Marginal effects of authority, with 95% CIs") ///
xtitle("Left-right ideology") ///
xla(1(1)11, valuelabel) xlabel(1 "a bad thing" 2 "neither good nor bad" 3 "a good thing") graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Some power" 2 "Extensive power")) ///
saving(int_intcoop_de, replace) title(Germany)

twoway /// 
(connected _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// extensive power  
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)), ///   extensive power
ytitle("Marginal effects of social purpose, with 95% CIs") ///
xtitle("International cooperation is a...") ///
xla(1(1)11, valuelabel) xlabel(1 "a bad thing" 2 "neither good nor bad" 3 "a good thing") graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(2 "Extensive power")) ///
saving(int_intcoop_de_only_sig, replace) title(Germany)


*Figure 7.9 - AMCE - see separate code for marginal means


use "purpose_us_pooled.dta", clear
set scheme plotplain

regress conf_cont i.purposeR2##c.lr i.power ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
qui margins, at(lr=(1(1)11) ) vsquish vce(uncond) dydx(purposeR2) saving(margins_lr_us, replace) 
use margins_lr_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6

*ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(connected _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(connected _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) , ///   
ytitle("Marginal effects of social purpose, with 95% CIs") ///
xtitle("Left-right ideology") ///
xla(1(1)11, valuelabel) xlabel(1 "Left" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "Right") graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Promote free trade" 2 "Combat climate change")) ///
saving(int_lr_us, replace) title(US)


*Figure 7.10 - AMCE - see separate code for marginal means


use "purpose_de_pooled.dta", clear
regress conf_cont i.purposeR2##c.lr i.power ///
i.transR i.partR i.fairR i.problemR [aweight=weight] if attentive==1, vce(cluster id)
qui margins, at(lr=(1(1)11) ) vsquish vce(uncond) dydx(purposeR2) saving(margins_lr_de, replace) 
use margins_lr_de.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6

ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(connected _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(connected _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health 
(connected _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(connected _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health  
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)), ///   
ytitle("Marginal effects of social purpose, with 95% CIs") ///
xtitle("Left-right ideology") ///
xla(1(1)11, valuelabel) xlabel(1 "Left" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "Right") graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Reduce poverty" 2 "Protect human rights" 3 "Combat climate change" 4 "Promote public health")) 


*Interaction analysis


use purpose_us_pooled.dta, clear
tab know_correct_index
tab know_correct_index, nol

regress conf_cont i.purposeR2##i.know_correct_index i.power ///
i.transR i.partR i.fairR i.problemR [aweight=weight]  if attentive==1, vce(cluster id)
qui margins, at(know_correct_index=(0(1)2)) vsquish vce(uncond) dydx(purposeR2) saving(margins_know_us, replace) 
use margins_know_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6 
ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(scatter _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(scatter _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health
(scatter _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(scatter _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(scatter _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health 
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)) , ///   
ytitle("Marginal effects of social purpose, with 95% CIs") ///
xtitle("Knowledge index") ///
xla(1(1)3, valuelabel) xlabel(1 "1" 2 "2" 3 "3")  graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Reduce poverty" 2 "Protect human rights" 3 "Promote free trade" 4 "Combat climate change" 5 "Promote public health")) ///
title(US) saving(int_know_us, replace) 

graph combine int_know_us.gph int_know_de.gph , saving(Fig5.1_know.gph) ycommon



use purpose_us_pooled.dta, clear
tab know_correct_index
tab know_correct_index, nol

regress conf_cont i.power##i.know_correct_index i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight]  if attentive==1, vce(cluster id)
qui margins, at(know_correct_index=(0(1)2)) vsquish vce(uncond) dydx(power) saving(margins_know_us, replace) 
use margins_know_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6 
ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(scatter _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(scatter _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health
(scatter _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(scatter _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(scatter _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health 
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)) , ///   
ytitle("Marginal effects of authority, with 95% CIs") ///
xtitle("Knowledge index") ///
xla(1(1)3, valuelabel) xlabel(1 "1" 2 "2" 3 "3")  graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Some power" 2 "Extensive power")) ///
title(US) saving(int_know_us, replace) 

graph combine int_know_us.gph int_know_de.gph , saving(Fig5.1_know.gph) ycommon




use purpose_de_pooled.dta, clear
tab know_correct_index
tab know_correct_index, nol

regress conf_cont i.power##i.know_correct_index i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight]  if attentive==1, vce(cluster id)
qui margins, at(know_correct_index=(0(1)2)) vsquish vce(uncond) dydx(power) saving(margins_know_de, replace) 
use margins_know_de.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6 
ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(scatter _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(scatter _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health
(scatter _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(scatter _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(scatter _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health 
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)) , ///   
ytitle("Marginal effects of authority, with 95% CIs") ///
xtitle("Knowledge index") ///
xla(1(1)3, valuelabel) xlabel(1 "1" 2 "2" 3 "3")  graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Some power" 2 "Extensive power")) ///
title(Germany) saving(int_know_de, replace) 


graph combine margins_edu_us_S3.a.gph margins_edu_de_S3.a.gph , saving(FigS3a.gph) ycommon



use purpose_us_pooled.dta, clear
tab educ
tab educ, nol

regress conf_cont i.purposeR2##i.educ i.power ///
i.transR i.partR i.fairR i.problemR [aweight=weight]  if attentive==1, vce(cluster id)
qui margins, at(educ=(1(1)6)) vsquish vce(uncond) dydx(purposeR2) saving(margins_edu_us, replace) 
use margins_edu_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6 
ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
twoway ///
(scatter _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(scatter _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health
(scatter _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(scatter _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(scatter _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health 
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)) , ///   
ytitle("Marginal effects of social purpose, with 95% CIs") ///
xtitle("Education") ///
xla(1(1)6, valuelabel) xlabel(1 "No high school" 2 "High school" 3 "Some college" 4 "2-year" 5 "4-year" 6 "Post-grad")  graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Reduce poverty" 2 "Protect human rights" 3 "Promote free trade" 4 "Combat climate change" 5 "Promote public health")) ///
title(US) saving(int_edu_us, replace) 


graph combine int_edu_us.gph int_edu_de.gph , saving(Fig5.1_edu.gph) ycommon


regress conf_cont i.power##i.educ i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight]  if attentive==1, vce(cluster id)
qui margins, at(educ=(1(1)6)) vsquish vce(uncond) dydx(power) saving(margins_edu_us, replace) 
use margins_edu_us.dta, clear
*ADDRESS OVERLAY PROBLEM
clonevar _mx = _at
replace _mx = cond(_deriv == 3, _mx - 0.1, _mx + 0.1) 
replace _mx=_mx-0.1 if _deriv==2
replace _mx=_mx+0.2 if _deriv==3
replace _mx=_mx+0.1 if _deriv==4
replace _mx=_mx+0.2 if _deriv==5
replace _mx=_mx+0.3 if _deriv==6 
ed _deriv _margin _ci_lb _ci_ub _at _mx

*MARGINSPLOT USING TWOWAY
set scheme plottig
twoway ///
(scatter _margin _mx if _deriv==2, lpattern(solid) msymbol(C)  color(black)) /// human rights
(scatter _margin _mx if _deriv==3, lpattern(dash) msymbol(S)  color(g3)) /// public health
(scatter _margin _mx if _deriv==4, lpattern(dot) msymbol(T)  color(g6)) ///  
(scatter _margin _mx if _deriv==5, lpattern(shortdash) msymbol(Oh)  color(g9)) ///  
(scatter _margin _mx if _deriv==6, lpattern(shortdash_dot) msymbol(Dh)  color(g12)) ///  
(rcap _ci_lb _ci_ub _mx if _deriv==2, sort pstyle(ci, width(medium))  color(black)) /// human rights
(rcap _ci_lb _ci_ub _mx if _deriv==3, sort pstyle(ci, width(medium)) color(g3)) /// public health 
(rcap _ci_lb _ci_ub _mx if _deriv==4, sort pstyle(ci, width(medium)) color(g6)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==5, sort pstyle(ci, width(medium)) color(g9)) ///   
(rcap _ci_lb _ci_ub _mx if _deriv==6, sort pstyle(ci, width(medium)) color(g12)) , ///   
ytitle("Marginal effects of authority, with 95% CIs") ///
xtitle("Education") ///
xla(1(1)6, valuelabel) xlabel(1 "No high school" 2 "High school" 3 "Some college" 4 "2-year" 5 "4-year" 6 "Post-grad")  graphregion(color(white)) ///
legend(pos(5) ring(0) cols(1) order(1 "Some power" 2 "Extensive power")) ///
title(US) 

graph combine int_edu_us.gph int_edu_de.gph , saving(Fig5.1_edu.gph) ycommon




*Robustness checks

*by attentiveness


* among all


*Regression models in chapter
*************************************


use "purpose_us_pooled.dta", clear

tab attentive
regress conf_cont i.power i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight], vce(cluster id)
estimates store conf_cont_us

*ACME graphs


*continuous DV
#delimit ;
coefplot(conf_cont_us), headings(1.power="{bf:Authority}" 1.purposeR2="{bf:Social Purpose}" 
1.transR="{bf:Transparency}" 1.partR="{bf:Participation}"
1.fairR="{bf:Fair Outcome}" 1.problemR="{bf:Problem-solving}") 
xline(0) drop(_cons) title("US") fxsize(60) base xtitle(Average marginal effects)
saving(conf_cont_us_nonatt.gph, replace)
;
#delimit cr


use "purpose_de_pooled.dta", clear

tab attentive
regress conf_cont i.power i.purposeR2 ///
i.transR i.partR i.fairR i.problemR [aweight=weight], vce(cluster id)
estimates store conf_cont_de

*ACME graphs


*continuous DV
#delimit ;
coefplot(conf_cont_de), headings(1.power="{bf:Authority}" 1.purposeR2="{bf:Social Purpose}" 
1.transR="{bf:Transparency}" 1.partR="{bf:Participation}"
1.fairR="{bf:Fair Outcome}" 1.problemR="{bf:Problem-solving}") 
xline(0) drop(_cons) title("Germany") fxsize(60) base xtitle(Average marginal effects)
saving(conf_cont_de_nonatt.gph, replace)
;
#delimit cr

graph combine conf_cont_us_nonatt.gph conf_cont_de_nonatt.gph //newFig7.4.gph




